/*
 * Copyright (C) 2014 Lucid Wolf
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.lucidhex.viewer.mapimport;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Icon;

/**
 *
 * @author Wolf
 */
public class ColorListIcon implements Icon{
    private int width = 50;
    private int height = 25;
    private final String name;
    private final Color color;
    public final String NOTHING = "NOTHING";
    public ColorListIcon(String name, Color color){
        if(name == null){
            this.name = NOTHING;
        }else{
            this.name = name;
        }
        this.color = color;
    }
    @Override
    public void paintIcon(Component cmpnt, Graphics g, int x, int y) {
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setColor(Color.WHITE);
        g2d.fillRect(x +1 ,y + 1,width-1 ,height-1 );
        g2d.setColor(color);
        g2d.fillRect(x +1 ,y + 1,height-1 ,height-1 );
        g2d.setColor(Color.BLACK);
        g2d.drawString(name, x+height+5, y+height-5);
        g2d.dispose();        
    }

    @Override
    public int getIconWidth() {
        return width;
    }

    @Override
    public int getIconHeight() {
        return height;
    }
    
}
